import {Injectable} from '@angular/core';
import {BaseHttpService} from "../base-http.service";
import {PageInfo, SearchCommonVO} from "../../types";
import {Observable} from "rxjs";

export interface BasicInformationList {
  id: number;
  dangerNo: string;
  cnName: string;
  alias?: string;
  dangerMatterKey: string;
  cas: string;
}

export interface BasicInformationAddEdit {
  id?: number;
  normalState: string;
  un: string;
  dangerNo: string;
  cnName: string;
  alias: string;
  cas: string;
}

@Injectable({
  providedIn: 'root'
})
export class BasicInformationService {

  constructor(public http: BaseHttpService) {
  }

  editBasicInformation(param: BasicInformationAddEdit): Observable<void> {
    return this.http.put('/identify', param, {needSuccessInfo: true});
  }

  addBasicInformation(param: BasicInformationAddEdit): Observable<void> {
    return this.http.post('/identify', param, {needSuccessInfo: true});
  }

  getBasicInformationDetail(id: number): Observable<BasicInformationAddEdit> {
    return this.http.get(`/identify/${id}`)
  }

  getBasicInformationList(param: SearchCommonVO<any>): Observable<PageInfo<BasicInformationList>> {
    return this.http.post('/identify/list', param);
  }

  delBasicInformation(ids: number[]): Observable<void> {
    return this.http.post(`/identify/del`, {ids: [ids]}, {needSuccessInfo: true})
  }

  /*展示已选中msdsEnterprise列表*/
  public getCheckList(id: number[]): Observable<any> {
    return this.http.post('/identify/checkList', {ids: id});
  }

  /*辨识表文档导出*/
  public getIdentifyExport(id: number[]): Observable<any> {
    return this.http.downZip('/word/identify-export', {ids: id})
  }
}
